import 'package:flutter/material.dart';
import 'package:flustars/flustars.dart';

// 国际化
class AppLocale with ChangeNotifier {
  Locale _locale = SpUtil.getString('locale', defValue: 'zh-CN') == 'zh-CN'
      ? const Locale('zh', 'CH')
      : const Locale('en', 'US');
  Locale get locale => _locale;

  // 语言切换
  void setLocale(Locale locale) {
    _locale = locale;
    switch (locale) {
      case const Locale('zh', 'CH'):
        SpUtil.putString('locale', 'zh-CN');
        break;
      case const Locale('en', 'US'):
        SpUtil.putString('locale', 'en-US');
      default:
        SpUtil.putString('locale', 'zh-CN');
        break;
    }
    // 配置接口国际化
    // ...
    notifyListeners();
  }
}

// 主题
class AppThemeMode with ChangeNotifier {
  // 主题默认白天
  ThemeMode _themeMode = SpUtil.getString('themeMode', defValue: 'light')! == 'dart'
      ? ThemeMode.dark
      : ThemeMode.light;

  ThemeMode get themeMode => _themeMode;

  // 主题切换
  void toggleTheme(ThemeMode themeMode) {
    _themeMode = themeMode;
    notifyListeners(); // 通知监听者更新UI
  }
}


// 隐私协议